<!DOCTYPE html>
<html>
<head>
    <title>登记缴款信息</title>
<#include "../common/common.ftl"/>
</head>
<body>
<div class="layui-fluid">
    <blockquote class="layui-elem-quote layui-bg-white">
        登记缴款信息:<br/>
        【姓名：<span class="jmdf-color-red">${(contract.name)!}</span>】【协议编号：<span
            class="jmdf-color-red">${(contract.contractCode)!}</span>】<br/>
        【总应缴款金额：<span
            class="jmdf-color-red">${(yjMoney)!}元</span>】
        【已缴款金额：<span
            class="jmdf-color-red">${(contract.handInMoney)!}元</span>】
        【剩余应缴款金额：<span
            class="jmdf-color-red">${(syMoney)!}元</span>】

    </blockquote>
    <form class="layui-form" id="chooseHouseForm">
        <input type="hidden" name="contractId" value="${(contract.id)!}"/>
        <input type="hidden" name="handInMoneyId" value="${(handInMoney.id)!}"/>
        <div class="layui-card">
            <div class="layui-card-header">缴款信息登记</div>
            <div class="layui-card-body">
                <div class="layui-form-item">
                    <div class="layui-col-xs12">
                        <div class="layui-inline">
                            <label class="layui-form-label">缴款类别：</label>
                            <div class="layui-input-block" style="width: 400px">
                                <select name="handInMoneyType" id="handInMoneyType" lay-verify="required">
                                    <option value="">--请选择--</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs12">
                        <div class="layui-inline">
                            <label class="layui-form-label">缴款时间：</label>
                            <div class="layui-input-block" style="width: 400px">
                                <input type="text" class="layui-input" id="handInMoneyDate" name="handInMoneyDate" lay-verify="required"
                                       value="${((handInMoney.handInMoneyDate)?string("yyyy-MM-dd"))!}">
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs12">
                        <div class="layui-inline">
                            <label class="layui-form-label">缴款金额：</label>
                            <div class="layui-input-inline" style="width: 150px">
                                <input type="text" class="layui-input" lay-verify="handInMoney" name="handInMoney"
                                       value="${(handInMoney.handInMoney)!}">
                            </div>
                            <#--<div class="layui-form-mid jmdf-color-red">
                                *（可输入的区间范围【0-${(syMoney)!}】）
                            </div>-->
                        </div>
                    </div>
                    <div class="layui-col-xs12">
                        <div class="layui-inline">
                            <label class="layui-form-label">缴款备注：</label>
                            <div class="layui-input-inline" style="width: 400px">
                                <textarea class="layui-textarea" cols="150" rows="5"
                                          name="handInMoneyMemo">${(handInMoney.handInMoneyMemo)!}</textarea>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <button style="display: none;" class="layui-btn" id="submitBtn" name="submitBtn" lay-submit=""
                lay-filter="submit">立即提交
        </button>
    </form>
</div>
<script src="/layui/layui.js" charset="utf-8"></script>
<script type="text/html" id="indexTpl">
    {{d.LAY_TABLE_INDEX+1}}
</script>
<script>
    layui.config({
        base: '/modules/' //静态资源所在路径
    }).use(['table', 'jquery', 'form', 'laydate', 'layer', 'verify', 'dataDict'], function () {
        var $ = layui.jquery, form = layui.form, dataDict = layui.dataDict, layer = layui.layer, laydate = layui.laydate,
                verify = layui.verify, parentIndex = parent.layer.getFrameIndex(window.name);
        //监听提交
        dataDict.select("缴款类别", "handInMoneyType",${(handInMoney.handInMoneyType)!});

        laydate.render({
            elem: '#handInMoneyDate'
            , type: 'date'
            , format: 'yyyy-MM-dd'
        });
        //监听提交
        form.on('submit(submit)', function (data) {
            $.ajax({
                url: 'handInMoneySave',
                type: 'post',
                data: data.field,//当前容器的全部表单字段，名值对形式：{name: value}
                success: function (data) {
                    if (data.code == "0001") {
                        layer.alert(data.message);
                        parent.loadData();
                        parent.layer.close(parentIndex);
                    } else {
                        layer.msg(data.message, {anim: 6, icon: 2, time: 3000});
                    }
                }
            });
            return false;
        });
       /* //自定义验证规则
        form.verify({
            handInMoney: function (value) {
                var r = /^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$/;
                var handInMoney = $("input:text[name='handInMoney']").val();
                var syMoney = ${(syMoney)!};
                if (value != undefined) {
                    if (!r.test(value) || (handInMoney - syMoney) > 0) {
                        return "请输入【0-" + syMoney + "】之间的数字！";
                    }
                } else {
                    return '必填项不允许为空！';
                }
            }
        });*/
    });
</script>
</body>
</html>